import pandas as pd
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt

data = pd.read_csv("generated_data.csv")

x = data.loc[:, 'x']
y = data.loc[:, 'y']

plt.figure(figsize=(10, 10))
plt.scatter(x,y)
plt.show()

#建立模型
lr_model = LinearRegression()
lr_model.fit(x.values.reshape(-1,1), y)

y_predict = lr_model.predict(x)